package com.bestsonic.crawler.utils;

import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.FileWriter;
import java.io.IOException;

public class StreamUtils {
	public static void closeStream(Closeable c){
		try {
			if(c != null) c.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public static void write2File(String content, String path) {
		BufferedWriter bufin = null;
		try {
			bufin = new BufferedWriter(new FileWriter(path, true));
			bufin.write(content);
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			StreamUtils.closeStream(bufin);

		}
	}
}
